package com.woniu.sharepark.intercepter;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 使用需要到WebMvcConfig添加自定义拦截器
 */
public class AuthInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      /*  System.out.println("拦截中。。");
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        String uri = request.getRequestURI();
        if (uri.endsWith("login") || uri.endsWith("doLogin") || uri.endsWith(".js") ||
                uri.endsWith(".css") || uri.endsWith(".gif") || uri.endsWith(".png")) {
            return true;
        }
        User user = (User) session.getAttribute(SystemConstant.CURRENT_USER);
        if (user == null) {
            response.sendRedirect("login");
            return false;
        }
        return true;
    }*/
        return true;
    }
}
